/*
 * @Author: Tim
 * @Date: 2020-08-11 11:22:10
 * @LastEditTime: 2020-08-11 11:56:11
 * @LastEditors: Please set LastEditors
 * @Description: 路由相关的管理 && 操作
 * @FilePath: /afire/utils/Router.class.js
 */
export default class Router {
    /**
     * 通用页面跳转方法
     * @param {*} e 
     */
    static jump(e) {
        if (!e) return;
        let url;
        if (typeof e === "string") url = e;
        else {
            url = ((e.currentTarget || {}).dataset || {}).url || e.url;

            let params = ((e.currentTarget || {}).dataset || {}).params || e.params || {};
            if (Object.keys(params).length > 0) {
                let pArr = [];
                for (let p in params) {
                    pArr.push(`${p}=${params[p]}`);
                }

                url += `?${pArr.join('&')}`;
            }
        }

        console.log('[Router.class.js]', 'onJump() --->', url);

        //在起始页面跳转到目标页面
        uni.navigateTo({
            url
        });
    };
}